﻿using System;
using FluentAssertions;
using Hopscotch.Common.Contracts.AppService;
using Hopscotch.Presentation.Common.Commands;
using Hopscotch.Test.Presentation;
using Moq;
using NUnit.Framework;

namespace Hopscotch.Presentation.Common.Test.Commands
{
    [TestFixture]
    public class NewEntityCommandTest
    {
        private NewEntityCommand<TestEntity, int> newEntityCommandTest;

        private Mock<IToolViewModel<TestEntity, int>> mockTestEntityViewModel;
        private Mock<IDomainService<TestEntity, int>> mockTestEntityService;

        [SetUp]
        public void SetUp()
        {
            mockTestEntityViewModel = new Mock<IToolViewModel<TestEntity, int>>();
            mockTestEntityService = new Mock<IDomainService<TestEntity, int>>();

            newEntityCommandTest = new NewEntityCommand<TestEntity, int>(mockTestEntityViewModel.Object);//, mockTestEntityService.Object);
        }

        [TestCase(ToolEditMode.None, true)]
        [TestCase(ToolEditMode.Update, false)]
        [TestCase(ToolEditMode.New, false)]
        public void TestCanExecuteShouldBeExpected(ToolEditMode toolEditMode, bool expected)
        {
            mockTestEntityViewModel.Setup(s => s.ToolEditMode).Returns(toolEditMode);
            newEntityCommandTest.CanExecute(null).Should().Be(expected);
        }

        [Test]
        public void TestExecuteShouldSetEditModeToNew()
        {
            mockTestEntityViewModel.SetupProperty<ToolEditMode>(p => p.ToolEditMode);
            newEntityCommandTest.Execute(null);
            mockTestEntityViewModel.Object.ToolEditMode.Should().Be(ToolEditMode.New);
        }
    }
}
